package com.apps.sdses.flink141.jar;

import com.alibaba.fastjson2.JSON;
import com.apps.sdses.flink141.source.AppMarketingDataSource;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;

import java.util.Properties;

/**
 * @author jiwei
 * @description
 * @date 2023/6/13 0:38
 */
public class CustomSource2Kafka {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(5);

        env.addSource(new AppMarketingDataSource())
                .map(JSON::toJSONString)
                .print();


        Properties properties = new Properties();
        properties.setProperty("bootstrap.servers", "localhost:9092");
        properties.setProperty("group.id", "test");
        DataStream<String> stream = env
                .addSource(new FlinkKafkaConsumer<>("topic", new SimpleStringSchema(), properties));





        env.execute();

    }
}
